package org.example.domain;

import org.example.Strategy.DiscountStrategy;

import java.math.BigDecimal;

//商品类
public class Product {
    //商品名称
    private String name;
    //商品价格
    private BigDecimal price;
    //单品价格
    private DiscountStrategy discountStrategy;

    public Product(String name, BigDecimal price, DiscountStrategy discountStrategy) {
        this.name = name;
        this.price = price;
        this.discountStrategy = discountStrategy;
    }

    public BigDecimal calculatePrice(int quantity) {
        return discountStrategy.applyDiscount(price,  quantity);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public DiscountStrategy getDiscountStrategy() {
        return discountStrategy;
    }

    public void setDiscountStrategy(DiscountStrategy discountStrategy) {
        this.discountStrategy = discountStrategy;
    }


}
